<template>
  <div class="about">
    <van-search
      v-model="value"
      placeholder="请输入搜索关键词"
      show-action
      shape="round"
      @input="kwshow"
    
    >
      <template #action>
        <span @click="search">搜索</span>
      </template>
    </van-search>

    <div>
      <!-- 搜索历史 -->
      <div v-show="show">
        <div class="search_box_top">
          <span>最近搜索</span>
          <van-icon name="delete" @click="del" />
        </div>
        <div class="search_box_list">
          <van-tag
            size="medium"
            v-for="(item,index) in includesList"
            :key="index"
            style="margin: 2px;"
          >{{item}}</van-tag>
        </div>
      </div>
      <!-- 搜索关键词 -->
      <div class="seared_item_box" v-show="!show">
        <div v-for="(item,index) in kwshowlist" :key="index">{{item.title}}</div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  data() {
    return {
      value: "",
      show: true
    };
  },
  methods: {
    del() {},
    kwshow() {
      this.show = this.value.length == 0;
      this.$store.dispatch('KWSSHOW',this.value)
    },
    search() {
      this.$router.push("/cart")
      this.$store.dispatch('SEARCHLIST',this.value)
    }
  },
  computed:{
    kwshowlist(){
      return this.$store.state.kwshowlist
    },
    includesList(){
       return this.$store.state.includesList
    }
  }
};
</script>
<style scoped>
.search_box_top {
  display: flex;
  justify-content: space-between;
  text-align: center;
  align-items: center;
  padding: 8px;
  /* width: 100%; */
  height: 30px;
  border-top: 1px solid #eeee;
}
.search_box_list {
  display: flex;
  flex-wrap: wrap;
  text-align: center;
  align-items: center;
  justify-content: flex-start;
}
.seared_item_box > div {
  width: 100%;
  height: 34px;
  line-height: 34px;
  text-indent: 1rem;
  font-size: 11.3px;
  border-bottom: 1px solid red;
}
</style>